<template>
  <div class="goods-list-item" @click="btn(goodsItem.gid)">
    <!-- 我是goodsitem:{{goodsItem}} -->
    <img :src="goodsItem.ItemImage" alt="" />
    <div class="goods-info">
      <p class="item-title">{{ goodsItem.title }}</p>
      <span>{{ goodsItem.price }}</span>
      <i class="el-icon-star-off"></i>
      <span>{{ goodsItem.cfav }}</span>
    </div>
    <!-- <div @click="btn(goodsItem.gid)">
      点击
    </div> -->
  </div>
</template>

<script>
export default {
  name: "GoodsListItem",
  props: {
    goodsItem: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  data() {
    return {};
  },
  computed: {},
  watch: {},
  methods: {
    // 点击商品跳转到详情页
    btn(index){
      // alert('点击的是---'+index)    
      // this.$router.push('/detail')
      this.$router.push({name:'/detail',query:{item:index}})
    }
  },
};
</script>

<style scoped>
.goods-list-item {
  position: relative;
  width: 165px;
  margin: 0 10px;
  margin-bottom: 10px;
  border: 1px solid grey;
  border-radius: 10px;
  /* text-align: center; */
}
.goods-list-item img {
  width: 100%;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
}
.goods-info {
  text-align: center;
}
.goods-info p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
</style>
